<template>
  <div class="all_box_center">
    <el-header height="45px">
      <el-row class="header_row">
        <el-col :span="2" :offset="3" class="home_page">
          <el-link href="searched" target="_self" icon="el-icon-back">回到主页</el-link>
        </el-col>
        <el-col :span="2" :offset="14" class="home_page">
          <el-link @click="logout()">退出登录</el-link>
        </el-col>

        <el-col :span="2" :offset="1" class="home_page" v-if="this.$store.getters.getUserId == 1">
          <el-link href="home">admin入口</el-link>
        </el-col>

      </el-row>
    </el-header>
    <div style="background-color:#FCFCFC;font-family:'宋体';height:100%;">
      <div style="margin-top:25px;margin-left:80px;">
        <el-row :gutter="10">
          <el-col :span="2">
            <div
              style="background-color:#FFEBCD;width:60px;height:60px;display:inline-block;border-radius:50%;overflow:hidden;"
              v-model="userInfo">
              <el-image :src="userInfo.headAddr" style="width:60px;height:60px;"></el-image>
            </div>
            <div style="margin-top:5px;margin-left:6px;"><span v-model="userInfo">{{userInfo.username}}</span></div>
            <div style="margin-top:50px;margin-left:1px;">
              <el-button type="text" style="font-size:15px;color:#4D4D4D;" @click.stop="infomationClick()">个人信息<span
                  style="color:#B0E0E6;" v-show="infomationShow" class="el-icon-s-promotion"></span></el-button>
            </div>
            <div style="margin-top:5px;margin-left:1px;">
              <el-button type="text" style="font-size:15px;color:#4D4D4D;" @click="passwordClick()">信息修改<span
                  style="color:#B0E0E6;" v-show="passwordShow" class="el-icon-s-promotion"></span></el-button>
            </div>
            <div style="margin-top:5px;margin-left:1px;">
              <el-button type="text" style="font-size:15px;color:#4D4D4D;" @click="bookClick()"
                v-show="this.userInfo.upRight">上传书籍<span style="color:#B0E0E6;" v-show="bookShow"
                  class="el-icon-s-promotion"></span></el-button>
            </div>
            <div style="margin-top:5px;margin-left:1px;">
              <el-button type="text" style="font-size:15px;color:#4D4D4D;" @click="collClick()">收藏夹<span
                  style="color:#B0E0E6;" v-show="collShow" class="el-icon-s-promotion"></span></el-button>
            </div>
          </el-col>

          <el-col :span="21">
            <el-row :gutter="10" style="margin-top:20px;">
              <el-col :span="5">{{USER_ID}}</el-col>
            </el-row>
<!-- 信息展示 -->
            <el-row v-show="infomationShow">
              <el-card style="margin-top:30px;">
                <el-row>
                  <el-col :span="6">
                    <el-row :gutter="12" style="margin-top:20px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>用户名：</span></div>
                      </el-col>
                      <el-col :span="16" v-model="userInfo">{{userInfo.username}}</el-col>
                    </el-row>
                    <el-row :gutter="12" style="margin-top:30px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>手机号：</span></div>
                      </el-col>
                      <el-col :span="16" v-model="userInfo">{{userInfo.phone}}</el-col>
                    </el-row>
                    <el-row :gutter="12" style="margin-top:30px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>电子邮箱：</span></div>
                      </el-col>
                      <el-col :span="16" v-model="userInfo">{{userInfo.email}}</el-col>
                    </el-row>
                    <el-row :gutter="12" style="margin-top:30px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>注册时间：</span></div>
                      </el-col>
                      <el-col :span="16" v-model="userInfo">{{userInfo.created | dateYMDHMSFormat}}</el-col>
                    </el-row>
                  </el-col>
                  <el-col :span="18">


                    <el-timeline v-for="msg in msgList">
                      <el-timeline-item :timestamp="msg.time | dateYMDHMSFormat" placement="top">
                        <!--                            <el-card>
                              <div><span><span
                                    style="font-family:'宋体';font-size:15px;"><strong>发送方: {{msg.send}}</strong></span><span
                                    style="font-family:'宋体';font-size:12px;margin-left:20px;"></span></span></div>
                              <div><<span>内容</span></div>
                            </el-card> -->
                        <el-card>
                          <el-row class="msg_row">
                            <el-col :span="20" class="msg_col">
                              <h3>发送方: {{msg.sendName}}</h3>
                              <p>{{msg.message}}</p>
                            </el-col>
                            <el-col :span="2" class="unread_msg_col" v-if="!msg.readed">
                              <el-button type="success" round @click="tap_read(msg.id)" size="small">未读</el-button>
                            </el-col>
                            <el-col :span="2" class="readed_msg_col" v-if="msg.readed" >
                              <el-button type="info" round disabled size="small">已读</el-button>
                            </el-col>
                            <el-col :span="2" class="del_msg_col">
                              <el-button type="danger" icon="el-icon-delete" circle @click="del_msg(msg.id)" size="small">
                              </el-button>
                            </el-col>
                          </el-row>

                        </el-card>
                      </el-timeline-item>
                    </el-timeline>


                  </el-col>
                </el-row>
              </el-card>
            </el-row>
<!-- 信息修改 -->
            <el-row v-show="passwordShow">
              <el-card style="margin-top:30px;">
                <el-col :span="9">
                  <el-form :model="userInfo">
                    <el-row :gutter="12" style="margin-top:20px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>用户：</span></div>
                      </el-col>
                      <el-col :span="10">
                        <el-form-item prop="username">
                          <el-input type="text" v-model="usernameUpda" placeholder="请输入您的用户名"
                            @keyup.enter.native="updateUsername"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="12" style="margin-top:1px;">
                      <el-col :span="8">
                        <div style="text-align:right;"><span>邮箱地址：</span></div>
                      </el-col>
                      <el-col :span="10">
                        <el-form-item prop="phone">
                          <el-input type="text" v-model="userInfo.email" placeholder="修改邮箱地址"
                            @keyup.enter.native="updateEmail"></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="14" style="margin-top:25px;">
                      <el-col :span="7" :offset="8">
                        <div class="pwd_phone_button">
                          <el-button type="primary" @click="changePhoneButton">手机号修改</el-button>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row :gutter="14" style="margin-top:25px;margin-bottom: 30px;">
                      <el-col :span="7" :offset="8">
                        <div class="pwd_phone_button">
                          <el-button type="primary" @click="changePwdButton">密码修改</el-button>
                        </div>
                      </el-col>
                    </el-row>
                  </el-form>
                </el-col>

<!-- 手机号修改 -->
                <el-col :span="15" v-show="showChangePhoneBox">
                  <div class="pwd_phone_tip">
                   <h3>手机号修改：</h3>
                  </div>
                  <div class="pwd_phone_step">
                   <el-steps :active="active" simple finish-status="success">
                    <el-step title="1 : 原手机号验证" icon="el-icon-edit-outline"></el-step>
                    <el-step title="2 : 新手机号验证" icon="el-icon-mobile"></el-step>
                    <el-step title="3 : 成功" icon="el-icon-check"></el-step>
                    </el-steps>
                  </div>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==0">
                    <!-- <el-input ></el-input> -->
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="userInfo.phone"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyPhone">确定</el-button>
                        </el-col>
                      </el-row>
                      <el-row style="height: 40px;margin-top: 10px;" v-show="showOldVeriCode">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="verifyCode"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyCodeInput">提交验证码</el-button>
                        </el-col>
                      </el-row>
                  </el-row>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==1">
                    <!-- <el-input ></el-input> -->
                 <!--     <el-row style="background-color: #0077AA;height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="verifyCode"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyCodeInput">提交验证码</el-button>
                        </el-col>
                      </el-row> -->
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="newPhone"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyNewPhone">确定</el-button>
                        </el-col>
                      </el-row>
                      <el-row style="height: 40px; margin-top: 10px;" v-show="showNewVeriCode">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="verifyNewCode"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyNewCodeInput">提交验证码</el-button>
                        </el-col>
                      </el-row>
                  </el-row>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==2">
                    <!-- <el-input ></el-input> -->
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="6">
                          <h2>手机号修改成功 ! ! !</h2>
                        </el-col>
                      </el-row>
                  </el-row>
                </el-col>

<!-- 密码修改 -->
                <el-col :span="15" v-show="!showChangePhoneBox">
                  <div class="pwd_phone_tip">
                   <h3>密码修改：</h3>
                  </div>
                  <div class="pwd_phone_step">
                   <el-steps :active="active" simple finish-status="success">
                    <el-step title="1 : 手机号验证" icon="el-icon-edit-outline"></el-step>
                    <el-step title="2 : 输入新密码" icon="el-icon-lock"></el-step>
                    <el-step title="3 : 成功" icon="el-icon-check"></el-step>
                    </el-steps>
                  </div>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==0">
                    <!-- <el-input ></el-input> -->
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="userInfo.phone"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyPhone">发送验证码</el-button>
                        </el-col>
                      </el-row>
                      <el-row style="height: 40px;margin-top: 10px;" v-show="showOldVeriCode">
                        <el-col :span="8" :offset="5">
                          <el-input v-model="verifyCode"></el-input>
                        </el-col>
                        <el-col :span="2" :offset="1">
                          <el-button type="primary" plain @click="verifyCodeInput">提交验证码</el-button>
                        </el-col>
                      </el-row>
                  </el-row>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==1">
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="5">
                          <el-input type="password" v-model="newPwd" placeholder="输入新密码"></el-input>
                        </el-col>

                      </el-row>
                     <el-row style="height: 40px;margin-top: 10px;">
                       <el-col :span="8" :offset="5">
                         <el-input type="password"  v-model="newPwdVerify" placeholder="确认新密码"></el-input>
                       </el-col>
                       <el-col :span="2" :offset="1">
                         <el-button type="primary" plain @click="verifyNewPwd">确定修改</el-button>
                       </el-col>
                     </el-row>
                  </el-row>
                  <el-row class="step_details_area" style="height: 200px;" v-if="active==2">
                    <!-- <el-input ></el-input> -->
                      <el-row style="height: 40px;margin-top: 65px;">
                        <el-col :span="8" :offset="6">
                          <h2>密码修改成功 ! ! !</h2>
                        </el-col>
                      </el-row>
                  </el-row>
                </el-col>
              </el-card>
            </el-row>
            <!-- 上传书籍 -->
            <el-row v-show="bookShow && this.userInfo.upRight">
              <el-card style="margin-top:30px;">
                <el-form :model="bookForm">
                  <el-row :gutter="12" style="margin-top:20px;">
                    <el-col :span="6">
                      <div style="text-align:right;"><span>书名：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="username">
                        <el-input type="text" v-model="bookForm.name" placeholder="请输入书籍名"></el-input>
                      </el-form-item>
                    </el-col>

                    <el-col :span="6">
                      <div style="text-align:right;"><span>stage：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="username">
                        <el-input type="text" v-model="bookForm.stage" placeholder="请输入书籍所在层级"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="12" style="margin-top:1px;">
                    <el-col :span="6">
                      <div style="text-align:right;"><span>作者：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.author" placeholder="请输入作者"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <div style="text-align:right;"><span>价格：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.price" placeholder="请输入价格"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="12" style="margin-top:1px;">
                    <el-col :span="6">
                      <div style="text-align:right;"><span>作者地址：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.authorAddr" placeholder="请输入作者的简介地址"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <div style="text-align:right;"><span>书籍简介：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.intro" placeholder="不超过30字"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="12" style="margin-top:1px;">
                    <el-col :span="6">
                      <div style="text-align:right;"><span>豆瓣评分：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.rate" placeholder="请输入豆瓣评分分数"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <div style="text-align:right;"><span>评分地址：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.rateAddr" placeholder="请输入豆瓣评分的地址"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="12" style="margin-top:1px;">
                    <el-col :span="6">
                      <div style="text-align:right;"><span>下载地址：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.downAddr" placeholder="请输入书籍的下载地址"></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="6">
                      <div style="text-align:right;"><span>封面地址：</span></div>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item prop="phone">
                        <el-input type="text" v-model="bookForm.faceAddr" placeholder="请输入书籍的封面地址"></el-input>
                      </el-form-item>
                    </el-col>
                  </el-row>
                  <el-row :gutter="12" style="margin-top:10px;">
                    <el-col :span="24" style="text-align:center;">
                      <el-button type="primary" plain round size="medium" @click="uploadBook()">提交</el-button>
                    </el-col>
                  </el-row>
                </el-form>
              </el-card>
            </el-row>
            <!-- 收藏夹 -->
            <el-row v-show="collShow">
              <el-card style="margin-top:30px;">
                <el-table :data="collList" border stripe @row-click="handleSeleBookId">
                  <el-table-column type="index" align="center" label="序号" width="100px"></el-table-column>
                  <el-table-column prop="name" align="center" label="书名" width="300px"></el-table-column>
                  <el-table-column prop="author" align="center" label="作者" width="200px"></el-table-column>
                  <el-table-column prop="price" align="center" label="价格" width="150px"></el-table-column>
                  <el-table-column prop="collTime" align="center" label="收藏时间" width="300px">
                    <template slot-scope="scope">
                      <!-- {{scope.row.price | priceFormat}} -->
                      {{scope.row.collTime | dateYMDHMSFormat}}
                    </template>
                  </el-table-column>
                </el-table>
              </el-card>
            </el-row>
          </el-col>
        </el-row>
      </div>

      <div>

      </div>
    </div>
  </div>

</template>
<script>
  import me from '../assets/images/loginBg.jpg'

  export default {
    created() {
      this.getUserTokenInfo()
      if (this.$route.query.type == 4) {
        this.collClick()
      } else {
        this.infomationClick()
      }
      this.$store.commit('refreshUserId', window.sessionStorage.getItem('userId'))
      this.$store.commit('refreshUserName', window.sessionStorage.getItem('userName'))
    },
    components: {
      // 'my-header': myheader
    },
    data() {
      return {
        USER_ID: '',
        src: me, //头像
        isCollapse: false, //是否水平折叠菜单
        infomationShow: false, //是否展示个人信息
        passwordShow: false, //密码展示,没啥用，效果一样
        isDisabled: false, //不禁用
        bookShow: false,
        collShow: false,
        userInfo: {},
        usernameUpda: '',
        bookForm: {
          stage: "00100010002",
          name: "",
          author: "",
          authorAddr: "",
          price: "0.00",
          uploader: window.sessionStorage.getItem('userId'),
          rate: "",
          rateAddr: "",
          downAddr: "",
          intro: "",
          faceAddr: "",
          verifyNewCode: ''
        },
        collList: [],
        msgList: [],
        active: 0,
        phoneBack: '',
        verifyCode: '',
        verifyNewCode: '',
        verifyCodeBack: '',
        showOldVeriCode: false,
        showNewVeriCode: false,
        newPhone: '',
        showChangePhoneBox: true,
        newPwd: '',
        newPwdVerify: ''
      }
    },
    methods: {
      handleOpen(key, keyPath) {
        console.log(key, keyPath)
        console.log(key)
        console.log(keyPath)
      },
      handleClose(key, keyPath) {

      },
      async getUserTokenInfo() {
        const {
          data: res
        } = await this.$http.get(`/user/getUserTokenInfo/${window.sessionStorage.getItem('userId')}`)
        this.phoneBack = res.data.phone

        let phoneStr = res.data.phone
        let firPhone = phoneStr.substr(0,3)
        let lastPhone = phoneStr.substr(7)

        this.userInfo = res.data
        this.userInfo.phone = firPhone+'****'+lastPhone
        this.usernameUpda = res.data.username
        console.log(res.data)
      },
      infomationClick() { //个人信息事件
        this.infomationShow = true
        this.passwordShow = false
        this.bookShow = false
        this.collShow = false
        this.getMsgList()
        this.timer = window.setInterval(() => {
          setTimeout(() => {
            this.getMsgList()
          }, 0)
        }, 3000)
      },
      passwordClick() { //密码事件
        this.passwordShow = true
        this.infomationShow = false
        this.bookShow = false
        this.collShow = false
      },
      bookClick() { //密码事件
        this.bookShow = true
        this.passwordShow = false
        this.infomationShow = false
        this.collShow = false
        // const {data: res} = await this.$http.get()
      },
      async collClick() {
        this.collShow = true
        this.bookShow = false
        this.passwordShow = false
        this.infomationShow = false

        const {
          data: res
        } = await this.$http.get(`/book/getCollList/${window.sessionStorage.getItem('userId')}`)
        console.log(res.data)
        this.collList = res.data
      },
      logout() {
        window.sessionStorage.clear()
        this.$store.commit('refreshUserId', 0)
        //2.用户访问登录页面
        this.$router.push('/login')
      },
      async uploadBook() {
        if (this.bookForm.stage === "") {
          this.$message.warning("书籍级别不能不能为空")
        } else if (this.bookForm.name === "") {
          this.$message.warning("书籍名不能为空")
        } else if (this.bookForm.author === "") {
          this.$message.warning("作者不能为空")
        } else if (this.bookForm.authorAddr === "") {
          this.$message.warning("作者地址不能为空")
        } else if (this.bookForm.price === "") {
          this.$message.warning("价格不能为空")
        } else if (this.bookForm.rate === "") {
          this.$message.warning("评分不能为空")
        } else if (this.bookForm.rateAddr === "") {
          this.$message.warning("评分地址不能为空")
        } else if (this.bookForm.downAddr === "") {
          this.$message.warning("下载地址不能为空")
        } else if (this.bookForm.intro === "") {
          this.$message.warning("简介不能为空")
        } else if (this.bookForm.faceAddr === "") {
          this.$message.warning("书籍封面不能为空")
        } else {
          const {
            data: res
          } = await this.$http.put("/user/addBookForm", this.bookForm)
          if (res.status != 200) return this.$message.error('书籍提交失败！');
          else this.$message.success("书籍信息提交成功!")
          // this.bookForm = []
        }

      },
      handleSeleBookId(row, event, column) {
        // console.log(row, event, column)
        // console.log(row.author)
        this.$router.push({
          path: '/bookdetails',
          query: {
            bookId: row.id
          }
        })
      },
      async getMsgList() {
        const {
          data: res
        } = await this.$http.get(`/msg/getMsgList/${window.sessionStorage.getItem('userId')}`)
        this.msgList = res.data
      },
      async del_msg(msgId) {
        const result = await this.$confirm('此操作将永久删除此消息, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).catch(error => error)

        //如果确认  confirm  如果取消 cancel
        if (result !== 'confirm') {
          return this.$message.info("取消删除")
        }
        const {
          data: result2
        } = await this.$http.delete(`/msg/deleteMsg/${msgId}`)
        if (result2.status !== 200) return this.$message.error("删除失败")
        this.$message.success("删除成功")
        //重新加载 数据
        this.getMsgList()
      },
      async updateUsername() {
        const {
          data: res
        } = await this.$http.put(
          `/user/updateUsernameById/${window.sessionStorage.getItem('userId')}/${this.usernameUpda}`)
        if (res.status != 200) return this.$message.error('用户名修改失败')
        this.$message.success("用户名修改成功")
        this.getUserTokenInfo()
      },
      async updateEmail() {
        const {
          data: res
        } = await this.$http.put(
          `/user/updateEmailById/${window.sessionStorage.getItem('userId')}/${this.userInfo.email}`)
        if (res.status != 200) return this.$message.error('邮箱修改失败')
        this.$message.success("邮箱修改成功")
        this.getUserTokenInfo()
      },
      verifyPhone(){
        if(this.phoneBack == this.userInfo.phone){
          this.$message.success("手机号验证成功")
          this.showOldVeriCode = true
          this.sendVerifyCode()
        }else{
          this.$message.error("手机号错误")
        }
      },
      async sendVerifyCode(){
        const {data: res} = await this.$http.get(`/user/getVerifyCode/${this.userInfo.phone}`)
        if (res.status != 200) return this.$message.error('验证码发送失败!');
        else {
          this.verifyCodeBack = res.data
          this.$message.success("验证码发送成功!")
        }
      },
      verifyCodeInput(){
        if(this.verifyCode == this.verifyCodeBack){
          this.$message.success("恭喜您，手机号验证成功!")
          this.active = 1
        }else{
          this.$message.error('验证码错误!')
        }
      },
      async verifyNewPhone(){
        if((/^1[3-9]\d{9}$/.test(this.newPhone))){
          const {data: res} = await this.$http.get(`/user/getVerifyCode/${this.newPhone}`)
          if (res.status != 200) return this.$message.error('验证码发送失败!');
          else {
            this.verifyCodeBack = res.data
            this.$message.success("验证码发送成功!")
            this.showNewVeriCode = true
          }
          console.log(res.data)
        }
        else{
          this.$message.error('手机号错误!')
        }
      },
      async verifyNewCodeInput(){
        if(this.verifyNewCode == this.verifyCodeBack){
          this.$message.success("恭喜您，手机号验证成功!")
          let userTo = {
            id: window.sessionStorage.getItem('userId'),
            phone: this.newPhone
          }
          const {data:res} = await this.$http.put('/user/updatePhoneById',userTo)
          if(res.status == 200){
            this.active = 2
            this.getUserTokenInfo()
          }else{
            this.$message.error('未知错误，修改失败!');
          }

        }else{
          this.$message.error('验证码错误!')
        }
      },
      changePhoneButton(){
        this.showChangePhoneBox = true
        this.active = 0
        this.showOldVeriCode = false
      },
      changePwdButton(){
        this.showChangePhoneBox = false
        this.active = 0
        this.showOldVeriCode = false
      },
      async verifyNewPwd(){
        if((this.newPwdVerify === this.newPwd) && (this.newPwd.length > 4)){
          let userTo = {
            id: window.sessionStorage.getItem('userId'),
            password: this.newPwdVerify
          }
          const {data:res} = await this.$http.put('/user/updatePwdById',userTo)
          if(res.status == 200){
            this.active = 2
          }else{
            this.$message.error('未知错误，密码修改失败!');
          }
        }else{
          this.$message.error('密码不一致或长度过短');
        }
      },
      async tap_read(msgId){
        const {data:res} = await this.$http.put(`/msg/changeToReaded/${msgId}`)
        if(res.status != 200) return this.$message.error('未知错误，读失败!');
        // console.log("msgId："+msgId+"---res.status："+res.status)
        this.$message.success("修改成功!")
        this.getMsgList()
      }
    },
    destroyed() {
            window.clearInterval(this.timer)
        }
  }
</script>

<style lang="less" scoped>
  .name {
    text-align: right;
  }

  .value {
    text-align: left;
  }

  .msg_row {
    display: block;

    .msg_col {}

    .del_msg_col, .unread_msg_col, .readed_msg_col {
      // vertical-align: middle;
      margin-top: 30px;
    }
  }

  .all_box_center {
    .el-header {
      line-height: 30px;
      background-color: #1d1d1f; //#303030

      .header_row {
        position: relative;
        top: 5px;

        .home_page {
          a {
            color: white;
            text-decoration: none;

            i {
              color: white;
            }
          }
        }
      }
    }
  }

  .pwd_phone_button {
    .el-button {
      padding: 0;
      width: 160px;
      height: 30px;
      // border: none;
    }
  }
</style>
